package spring.demo.ioc.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ImportResource;
import org.springframework.stereotype.Service;
import spring.demo.ioc.persistence.AccountDao;

import javax.annotation.Resource;

@Service("accountService")
public class AccountService {
    // Autowired 是按照类型搜索
    @Autowired
//    @Resource(name = "accountDao")
    private AccountDao accountDao; // 我们不管这个是怎么实现的，要不管内部构造是什么，我们只想要这样的一个对象

    public AccountService(AccountDao accountDao) {
        this.accountDao = accountDao;
    }

    public void login()
    {
        System.out.println("login...");
        accountDao.find();
    }
    public AccountDao getAccountDao() {
        return accountDao;
    }

    public void setAccountDao(AccountDao accountDao) {
        this.accountDao = accountDao;
    }
}
